package com.yykj.hospital.server.converter;

import com.yykj.hospital.client.dto.banci.DoctorBanCiOnlineListDTO;
import com.yykj.hospital.server.model.entity.banci.HospitalDoctorBanCi;
import org.springframework.beans.BeanUtils;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.stream.Collectors;

public class DoctorBanCiOnlineListDTOConverter {
    public static DoctorBanCiOnlineListDTO convert(HospitalDoctorBanCi item){
        DoctorBanCiOnlineListDTO dto = new DoctorBanCiOnlineListDTO();
        BeanUtils.copyProperties(item,dto);
        dto.setDay(item.getDay().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
        dto.setStartTime(item.getStartTime().format(DateTimeFormatter.ofPattern("HH:mm")));
        dto.setEndTime(item.getEndTime().format(DateTimeFormatter.ofPattern("HH:mm")));
        return dto;
    }

    public static List<DoctorBanCiOnlineListDTO> convert(List<HospitalDoctorBanCi> list){
        return list.stream().map(DoctorBanCiOnlineListDTOConverter::convert).collect(Collectors.toList());
    }
}
